<fieldset>
	<legend> Utilisateurs </legend>
		<br/>
			<div id="champs">
				<?php
					if (isset($message)) {
						echo "<p>";
						echo $message;
						echo "</p>";
					} else {
						$max = count($tab['id_user']);
						if (isset($_SESSION['droit'])) {
							if($_SESSION['droit'] == 1) {
								echo "<TABLE BORDER=","1",">
										<CAPTION> Liste des utilisateurs : </CAPTION>
										<TR>
											<TH> Index </TH>
											<TH> Mail </TH>
											<TH> Civilite </TH>
											<TH> Nom </TH>
											<TH> Prenom </TH>
											<TH> Mot de passe </TH>
											<TH> Droit </TH>
											<TH> Action </TH>
										</TR>";
								for($i=0 ; $i < $max ; $i++) {
									echo "<TR>";
									echo "<TD>", $tab['id_user'][$i], "</TD>";
									echo "<TD>", $tab['mail'][$i], "</TD>";
									echo "<TD>", $tab['civilite'][$i], "</TD>";
									echo "<TD>", $tab['nom'][$i], "</TD>";
									echo "<TD>", $tab['prenom'][$i], "</TD>";
									echo "<TD>", $tab['password'][$i], "</TD>";
									echo "<TD>", $tab['droit'][$i], "</TD>";
									$id = $tab['id_user'][$i];
									echo "<TD>";
									echo "<a href=\"index.php?page=view_user&id_user=$id\" onClick=\"affiche_cache('update_categ')\">";
									echo "<img src=\"./images/action/feuille.png\" title=\"Modifier l'utilisateur\"/>";
									echo "</a>";
									echo "<a href=\"index.php?page=delete_user&id_user=$id\">";
									echo "<img src=\"./images/action/croix.png\" title=\"Supprimer l'utilisateur\"/>";
									echo "</a>";
									echo "<a href=\"index.php?page=fiche_user&id_user=$id\">";
									echo "<img src=\"./images/action/loupe.png\"/ title=\"Voir la fiche utilisateur\">";
									echo "</a>";
									echo "</TD>";
									echo "</TR>";
								}
							}
						} 
						echo "</TABLE>";
					}
				?>
				<div id="update_user" style="display: <?php if (isset($display)) echo $display; else echo "none"; ?> ">
					</br>
					</br>
					<form method="post" action="index.php?page=admin_update_user" onSubmit="return verifForm(this)">
						<fieldset>
							<div id="champs_categ">
								<input name="id_user" value="<?php echo $tab['id_user'][0]; ?>" style="display: none"/>
								<label for="mail"> Mail : </label>
								<input name="mail" value="<?php echo $tab['mail'][0]; ?>"/><br/>
								<label for="civilite"> Civilite : </label>
								<?php
								$civilite = array ('Monsieur','Madame','Mademoiselle');
								echo "<select name=\"civilite\">";
									echo "<option>", $tab['civilite'][0], "</option>";
									for($i=0 ; $i < sizeof($civilite); $i++) {
										if ($civilite[$i] != $tab['civilite'][0])
											echo "<option>", $civilite[$i], "</option>";
									}
								echo "</select><br/>";
								?>
								<label for="nom"> Nom : </label>
								<input name="nom" value="<?php echo $tab['nom'][0]; ?>"/><br/>
								<label for="prenom"> Prenom : </label>
								<input name="prenom" value="<?php echo $tab['prenom'][0]; ?>"/><br/>
								<label for="password"> Mot de passe : </label>
								<input name="password" value="<?php echo $tab['password'][0]; ?>"/><br/>
								<label for="droit"> Droit : </label>
								<input name="droit" value="<?php echo $tab['droit'][0]; ?>"/><br/>
							</div> <!-- fin div champs_categ -->
						</fieldset>
						<p style="text-align:right"><input type="submit" value="Envoyer"/></p>
					</form>
				</div> <!-- fin div update_user --> 
			</div> <!-- fin div champs -->
</fieldset>

<?php
	if (isset($_GET['numpage'])) {
		echo "<ul id=\"choix\">";
			if ($_GET['numpage'] == 1 || ($_GET['numpage'] > $tab['nombreDePages'] && $tab['nombreDePages'] == 1))
				echo "<li class=\"page disabled\"> &lsaquo; Pre </li>";
			else {	
				$nb = $_GET['numpage'] - 1;
				if ($nb > $tab['nombreDePages'])
					$nb = 1;
				echo  "<li class=\"page\"><a href=\"index.php?page=user&numpage=$nb\"> &lsaquo; Pre </a></li>";
			}
			for ($i=1 ; $i <= $tab['nombreDePages'] ; $i++) {
				if ($_GET['numpage'] == $i)
					echo "<li class=\"num_page\" id=\"current_page\">
							<a href=\"index.php?page=user&numpage=$i\"> $i </a>
						  </li>";
				else
					echo "<li class=\"num_page\">
						<a href=\"index.php?page=user&numpage=$i\"> $i </a>
					  </li>";
			}
			if ($_GET['numpage'] >= $tab['nombreDePages'])
				echo "<li class=\"page disabled\"> Suiv &rsaquo; </li>";
			else {
				$nb = $_GET['numpage'] + 1;
				echo  "<li class=\"page\"><a href=\"index.php?page=user&numpage=$nb\"> Suiv &rsaquo; </a></li>";
			}
        echo "</ul>";
	}
?>		
		
